// FOR KEYBOARD INPUT

#include "SDL/SDL.h"


#include "GLOBALS.h"

enum input_type check_input(enum input_type old_key){
    input_type key_pressed=old_key;
    // Setup an SDL keyevent
    SLD_Event keyevent;
    SDL_PollEvent(&keyevent);
    // Only do something if a key is pressed
    if(keyevent.type==SDL_KEYDOWN){
      if(keyevent.key.keysym.sym==SDLK_LEFT || keyevent.key.keysym.sym==SDLK_a){ // Left key
	key_pressed=LEFT;
      }else if(keyevent.key.keysym.sym==SDLK_RIGHT || keyevent.key.keysym.sym==SDLK_d){ // Right key
	key_pressed=RIGHT;
      }else if(keyevent.key.keysym.sym==SDLK_UP || keyevent.key.keysym.sym==SDLK_w){ // Up key
	key_pressed=UP;
      }else if(keyevent.key.keysym.sym==SDLK_DOWN || keyevent.key.keysym.sym==SDLK_s){ // Down key
	key_pressed=DOWN;
      }else if(keyevent.key.keysym.sym==SDLK_ESCAPE){ // Escape key
	key_pressed=ESCAPE;
      }
    }
    return key_pressed;
  }